<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>FCMS后台管理系统</title>
    <meta name="description" content="overview &amp; stats" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/bootstrap.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/font-awesome/4.5.0/css/font-awesome.min.css" />
    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/jquery-ui.custom.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/chosen.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/bootstrap-datepicker3.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/bootstrap-timepicker.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/daterangepicker.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/bootstrap-datetimepicker.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/bootstrap-colorpicker.min.css" />
    <!-- text fonts -->
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/fonts.googleapis.com.css" />
    <!-- ace styles -->
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
    <!--[if lte IE 9]>
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/ace-part2.min.css" class="ace-main-stylesheet" />
    <![endif]-->
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/ace-skins.min.css" />
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/ace-rtl.min.css" />
    <!--[if lte IE 9]>
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/css/ace-ie.min.css" />
    <![endif]-->
    <!-- inline styles related to this page -->
    <link rel="stylesheet" href="<?=Yii::app()->request->baseUrl;?>/resource/backend/plugins/toastr/toastr.min.css" />
    <!-- ace settings handler -->
    <script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/ace-extra.min.js"></script>
    <!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->
    <!--[if lte IE 8]>
    <script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/html5shiv.min.js"></script>
    <script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">
    <script type="text/javascript">
        try{ace.settings.loadState('main-container')}catch(e){}
    </script>
    <!-- /.sidebar_left -->
    <div class="main-content">
        <div class="main-content-inner">
            <!-- PAGE CONTENT BEGINS -->
            <?=$content;?>
            <!-- PAGE CONTENT ENDS -->
        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->
<!-- basic scripts -->
<!--[if !IE]> --><script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/jquery-2.1.4.min.js"></script><!-- <![endif]-->
<!--[if IE]><script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/jquery-1.11.3.min.js"></script><![endif]-->
<script type="text/javascript">
    if('ontouchstart' in document.documentElement) document.write("<script src='<?=Yii::app()->request->baseUrl;?>/resource/backend/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/bootstrap.min.js"></script>
<!-- page specific plugin scripts -->
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/jquery-ui.custom.min.js"></script>
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/jquery.ui.touch-punch.min.js"></script>
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/chosen.jquery.min.js"></script>
<!-- ace scripts -->
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/ace-elements.min.js"></script>
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/ace.min.js"></script>
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/js/contabs.min.js"></script>
<!-- inline scripts related to this page -->
<script src="<?=Yii::app()->request->baseUrl;?>/resource/backend/plugins/toastr/toastr.min.js"></script>
<?php if(Yii::app()->user->hasFlash('success')){?>
<script>
jQuery(function ($) {
    toastr.options = {
        "closeButton": false,
        "debug": false,
        "positionClass": "toast-top-right",
        "onclick": null,
        "showDuration": "300",
        "hideDuration": "1000",
        "timeOut": "3000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    };
    toastr.success('更新成功', '提示');
});
</script>
<?php }?>
<script type="text/javascript">
    jQuery(function($) {
        $('#id-disable-check').on('click', function() {
            var inp = $('#form-input-readonly').get(0);
            if(inp.hasAttribute('disabled')) {
                inp.setAttribute('readonly' , 'true');
                inp.removeAttribute('disabled');
                inp.value="This text field is readonly!";
            }
            else {
                inp.setAttribute('disabled' , 'disabled');
                inp.removeAttribute('readonly');
                inp.value="This text field is disabled!";
            }
        });

        // AdForm Select input type
        var defaultType = $("select#adForm-input_type :selected").val();
        $(".form-group.field-adForm-ad").not(".input_"+defaultType).hide().find("input[name=AdForm\\[ad\\]], textarea[name=AdForm\\[ad\\]]").attr('disabled', true);
        $("select#adForm-input_type").change(function () {
            var type = parseInt( $(this).val() );
            $(".form-group.field-adForm-ad").hide().find("input[name=AdForm\\[ad\\]], textarea[name=AdForm\\[ad\\]]").attr('disabled', true);
            $(".form-group.field-adForm-ad.input_"+type).show().attr('name', 'AdForm[value]').find("input[name=AdForm\\[ad\\]], textarea[name=AdForm\\[ad\\]]").attr('disabled', false);
        });

        //
        if(!ace.vars['touch']) {
            $('.chosen-select').chosen({allow_single_deselect:true});
            //resize the chosen on window resize
            $(window)
                .off('resize.chosen')
                .on('resize.chosen', function() {
                    $('.chosen-select').each(function() {
                        var $this = $(this);
                        $this.next().css({'width': $this.parent().width()});
                    })
                }).trigger('resize.chosen');
            //resize chosen on sidebar collapse/expand
            $(document).on('settings.ace.chosen', function(e, event_name, event_val) {
                if(event_name != 'sidebar_collapsed') return;
                $('.chosen-select').each(function() {
                    var $this = $(this);
                    $this.next().css({'width': $this.parent().width()});
                })
            });

            $('#chosen-multiple-style .btn').on('click', function(e){
                var target = $(this).find('input[type=radio]');
                var which = parseInt(target.val());
                if(which == 2) $('#form-field-select-4').addClass('tag-input-style');
                else $('#form-field-select-4').removeClass('tag-input-style');
            });
        }

        //And for the first simple table, which doesn't have TableTools or dataTables
        //select/deselect all rows according to table header checkbox
        //全选checkbox或不全选
        var active_class = 'active';
        $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
            var th_checked = this.checked;//checkbox inside "TH" table header

            $(this).closest('table').find('tbody > tr').each(function(){
                var row = this;
                if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
                else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
            });
        });

        /*$('input[name="selection_all"]').on("click",function(){
            if($(this).is(':checked')){
                $('input[name="selection[]"]').each(function(){
                    $(this).prop("checked",true);
                });
            }else{
                $('input[name="selection[]"]').each(function(){
                    $(this).prop("checked",false);
                });
            }
        });*/

        //批量删除
        $('.multi-operate').on('click', function(){
            var data=new Array();
            $("input:checkbox[name='selection[]']").each(function (){
                if($(this).prop("checked")==true){
                    data.push($(this).val());
                }
            });
            //alert(data);
            if(data.length > 0){
                $.post('<?php echo CHtml::normalizeUrl(array('/'.$this->uniqueId.'/deleteAll'));?>', {'selection[]':data}, function (resp) {
                    var ret = $.parseJSON(resp);
                    //alert(resp);
                    if (ret.result) {
                        //alert("删除成功！");
                        //window.location('<?php echo $this->createUrl('/'.$this->uniqueId.'/index')?>');
                        window.location.href=window.location.href;
                        window.location.reload;
                        //$.fn.yiiGridView.update('yw1');
                    }
                });
            }else{
                alert("请选择要删除的内容!");
            }
        });

        //提示信息1秒后隐藏,fadeOut淡出效果，也可设置时间 1500
        $(".alert").show().delay(1000).fadeOut('slow');

        // thumb 删除
        $(".thumbDelete").click(function () {
            var fileUrl = $(this).parents('.image').find('img')[0].src;
            console.log(fileUrl);
        });

    });
</script>
<script type="text/javascript" src="<?=Yii::app()->request->baseUrl;?>/resource/backend/plugins/jquery.multifile.js"></script>
<script>
jQuery(function($) {
    // 添加多张图片，需要一张张添加
    $("#Article_images").MultiFile({'onFileSelect': function (e, v, m) {},'afterFileSelect': function (e, v, m) { /*alert("afterFileSelect - " + v)*/},'onFileAppend': function (e, v, m) {/*alert("onFileAppend - " + v)*/},'afterFileAppend': function (e, v, m) {/*alert("afterFileAppend - " + v)*/}, 'onFileRemove': function (e, v, m) {/*alert("onFileRemove - " + v)*/}, 'afterFileRemove': function (e, v, m) {/*alert("afterFileRemove - " + v)*/},
        'accept': 'jpeg\x7Cjpg\x7Cgif\x7Cpng','STRING': {'denied': 'Invalid\x20file\x20type', 'duplicate': 'Duplicate\x20file\x21'}
    });
    // 删除选中的组图
    $(".delMultiImage").click(function () {
        //console.log($(this).parent(".multi-item").children("input[type='hidden']").val());
        // Ajax delete this file
        var fileUrl = $(this).parent(".multi-item").children("input[type='hidden']").val();
        $.ajax({
            url:"<?=$this->createUrl('/backend/article/fileRemove')?>",
            type:"post",
            data:{"fileUrl":fileUrl},
            dataType:"json",
            success:function(data){
                if(data.state == "success"){
                    alert(data.message);
                }else{
                    alert(data.message);
                }
            },
        });
        // remove this select element and children element
        $(this).parent(".multi-item").remove(); //删除被选元素及其子元素
    });
});
</script>
</body>
</html>
